from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime

class DepartmentBase(BaseModel):
    """部门基础数据模式"""
    name: str
    parent_id: Optional[int] = None
    manager_id: Optional[int] = None
    description: Optional[str] = None

class DepartmentCreate(DepartmentBase):
    """创建部门时的数据模式"""
    pass

class DepartmentUpdate(BaseModel):
    """更新部门时的数据模式"""
    name: Optional[str] = None
    parent_id: Optional[int] = None
    manager_id: Optional[int] = None
    status: Optional[int] = None
    description: Optional[str] = None

class DepartmentInDB(DepartmentBase):
    """返回给用户的部门数据模式"""
    id: int
    status: int
    create_time: datetime
    update_time: Optional[datetime] = None
    employee_count: Optional[int] = None
    manager_name: Optional[str] = None
    parent_name: Optional[str] = None

    class Config:
        from_attributes = True

class DepartmentTree(DepartmentInDB):
    """部门树形结构"""
    children: List['DepartmentTree'] = [] 